#include "../source/server.hpp"

using namespace wyl;


void OnMessage(const PtrConnection& conn, Buffer* buf)
{
    DLOG("%s",buf->ReadPosition());
    buf->MoveReadOffset(buf->ReadAbleSize());
    std::string str = "hello world"; 
    conn->Send(str.c_str(),str.size());
}

void OnConected(const PtrConnection& conn)
{
    DLOG("NEW CONNECTION:%p",conn.get());
}

void OnClose(const PtrConnection& conn)
{
   DLOG("%d Connection alread shutdown!" , conn->Id());
}

int main()
{
  TcpServer svr(8082); 
  svr.SetThreadCount(2); 
  svr.EnableInactiveRelease(3);
  svr.SetClosedCallBack(OnClose);
  svr.SetMessageCallBack(OnMessage);
  svr.SetConnectedCallBack(OnConected);
  svr.Start();
  return 0;
}
